package br.com.webselector.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {
	
	private static JPAUtil me;
	private EntityManagerFactory factory;
	
	public JPAUtil(){
		factory = Persistence.createEntityManagerFactory("ConexaoOficial");
	}
	
	public static JPAUtil getInstance(){
		if(me == null){
			me = new JPAUtil();
		}
		return me;
	}
	
	public EntityManager createEntityManager(){
		EntityManager em = factory.createEntityManager();
		em.getTransaction().begin();
		return em;
	}

}
